package cn.initcap.concurrency.concurrency.immutable;

import cn.initcap.concurrency.annoations.NotThreadSafe;
import com.google.common.collect.Maps;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;

/**
 * 当final修饰引用变量时，只是当初始化后就不能指向新的引用，而当前的引用是可以修改值的，是线程不安全的。
 *
 * @author initcap
 * @date Created in 2018/6/15 PM6:36.
 */
@Slf4j
@NotThreadSafe
public class ImmutableExcample1 {

    private final static Integer A = 1;
    private final static String B = "a";
    private final static Map<Integer, Integer> MAP = Maps.newHashMap();

    static {
        MAP.put(1, 2);
        MAP.put(3, 4);
        MAP.put(5, 6);
    }

    public static void main(String[] args) {
        MAP.put(1, 3);
        log.info("{}", MAP.get(1));
    }

    private void test(final int a) {
        //a = 1;
    }

}
